# coding: utf-8
from kafka import KafkaProducer
import csv
import time,random

producer = KafkaProducer(bootstrap_servers='niit01:9092')
# csvfile = open("../data/user_log.csv","r")
# reader = csv.reader(csvfile)

# for line in (1,10000000):
#     gender = random.sample(8)
#     # gender = line[9]
#     # if gender == 'gender':
#         # continue
#     print(gender)
#     time.sleep(1)
#     producer.send('sex',gender.encode('utf8'))
for line in range(1,10000000):
    gender = random.randint(0, 2)
    num = random.randint(1, 10)
    genders = str(gender) + ',' + str(num)
    print('生产的数据为:'+ genders)
    time.sleep(1)
    producer.send('result2',genders.encode('utf8'))

# kafka + 生产 + spark 处理 + kafka +  flask/socketIO  || 报表工具
